package org.platform.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
import org.platform.tool.util.XmlUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.IOException;

/**
 * 任务检查项配置
 *
 * @author FengJie
 * @date 2018/8/23
 */
@Configuration

@Slf4j
public class CheckItemHelperConfig {

    @Bean
    public CheckItemHelper getCheckItem() {
        try {
            File file = ResourceUtils.getFile("classpath:config/TaskCheckItemConfiguration.xml");
            String xml = FileUtils.readFileToString(file);
            return XmlUtils.xmlToBean(xml, CheckItemHelper.class, true, "checkItem");
        } catch (IOException e) {
            log.error("读取系统任务检查项失败,异常信息:", e);
        }
        return new CheckItemHelper();
    }

}
